#!/usr/bin/perl
# parser.pl
use warnings;
use strict;

{
   package My::Pod::Parser;

   use Pod::Parser;

   our @ISA = qw(Pod::Parser);

   sub command {
      my ($parser, $cmd, $para, $line) = @_;
      my $fh = $parser->output_handle;

      $para =~s/[\n]+$//;
      my $output = $parser->interpolate($para, $line);
      print $fh "<pod:$cmd> $output </pod:$cmd> \n";
   }

   sub verbatim {
      my ($parser, $para, $line) = @_;
      my $fh = $parser->output_handle;

      $para =~s/[\n]+$//;
      print $fh "<pod:verbatim> \n $para \n </pod:verbatim> \n";
   }

   sub textblock {
      my ($parser, $para, $line) = @_;
      my $fh = $parser->output_handle;

      print $fh $parser->interpolate($para, $line);
   }

   sub interior_sequence {
      my ($parser, $cmd, $arg) = @_;
      my $fh = $parser->output_handle;

      return "<pod:int cmd=\"$cmd\"> $arg </pod:int>";
   }
}

my $parser = new My::Pod::Parser();

if (@ARGV) {
   $parser->parse_from_file($_) foreach @ARGV;
} else {
   $parser->parse_from_filehandle(\*STDIN);
}
